
package controller;

import java.io.PrintWriter;
import java.util.List;
import java.util.Collections;
import common.Match;
import interfaces.IItem;

public class ResultPrinter {
    int windowSize;
    int paneSize;
    PrintWriter output;
    
    public ResultPrinter(PrintWriter output, int windowSize, int paneSize){
        this.output=output;
        this.windowSize=windowSize;
        this.paneSize=paneSize;
    }
    
    public void print(List<List<Match>> matches){
        int currPane = paneSize;
        output.println("windowStart; windowStop; pattern; support");
        List<Match> windowMatches;
        
        for (int i=0; i<matches.size(); ++i){
            windowMatches = matches.get(i);
            Collections.sort(windowMatches);
            Collections.reverse(windowMatches);
            for (int j=0; j<windowMatches.size(); ++j){
                output.println(
                        Integer.toString(currPane-windowSize+1) + ";" +
                        currPane + ";" +
                        windowMatches.get(j).pattern.toString() + ";" +
                        windowMatches.get(j).support / windowSize *100 + "%"
                );
            }
            currPane+=paneSize;
        }
        
    }
}
